package com.sxt.sys.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sxt.sys.service.LogInfoService;
import com.sxt.sys.vo.LogInfoVo;

@Controller
@RequestMapping("logInfo")
public class LogInfoController {
	@Autowired
 private LogInfoService logInfoService;
	 @RequestMapping("toLogInfoManager")
	public String toLogInfoManager(){
		return "system/logInfoManager";
	}
	
	 @RequestMapping("loadAllLogInfo")
	 @ResponseBody
	 public Map<String, Object> loadAllLogInfo(LogInfoVo logInfoVo){
		return this.logInfoService.queryAllLogInfo(logInfoVo);
		 
	 }
		/*@RequestMapping("loadAllLogInfo")
		@ResponseBody
		public DataGridView loadAllLogInfo(LogInfoVo logInfoVo){
			return this.logInfoService.queryAllLogInfo(logInfoVo);
		}*/
	 @RequestMapping("deleteLoginInfo")
	 @ResponseBody
	 public Map<String,Object> deleteLoginInfo(LogInfoVo logInfoVo){
		Map<String,Object> map=new HashMap<>();
		try {
			this.logInfoService.deleteByPrimaryKey(logInfoVo.getId());
			map.put("msg", "删除成功");
			
		} catch (Exception e) {
		e.printStackTrace();
		map.put("msg", "删除失败");
		}
		
		 return map;
		 
	 }
	 @RequestMapping("deleteLoginInfos")
	 @ResponseBody
	 public Map<String,Object> deleteLoginInfos(LogInfoVo logInfoVo){
		Map<String,Object> map=new HashMap<>();
		try {
			String []	idss=logInfoVo.getIds();
			if(idss!=null&&idss.length>0){
				
				for (String id : idss) {
					this.logInfoService.deleteByPrimaryKey(Integer.parseInt(id));
				}
				map.put("msg", "删除成功");
			}
			
		} catch (Exception e) {
		e.printStackTrace();
		map.put("msg", "删除失败");
		}
		
		 return map;
		 
	 }
	 
}
